/*******************************************************************************
 * Copyright (c) 2005, 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package us.gaaoc.framework.dao;

import java.util.List;

import org.hibernate.FetchMode;
import org.hibernate.HibernateException;
import org.hibernate.criterion.Restrictions;

import us.gaaoc.framework.model.AddressCategory;
import us.gaaoc.framework.model.AddressType;
import us.gaaoc.framework.model.Person;

 

/**
 * Home object for domain model class AddressTypeDAOHibernate.
 * 
 * @see us.gaaoc.framework.model.AddressTypeDAOHibernate
 * @author Hibernate Tools
 */
public class AddressTypeDAOHibernate extends GenericHibernateDAO<AddressType, Integer, AddressTypeDAO>
implements  AddressTypeDAO{

	protected AddressTypeDAOHibernate() {}

	/* (non-Javadoc)
	 * @see us.gaaoc.framework.dao.AddressTypeDAO#findAddressType(int, us.gaaoc.framework.model.AddressCategory)
	 */
	public AddressType findAddressType(int addressTypeCode,
			AddressCategory addressCategory) {
		AddressType addressType = null;
		try {
			// eagerly fetch the Person object
			addressType = (AddressType) getSession().createCriteria(AddressType.class)
					.setFetchMode("*", FetchMode.SELECT)
				.add(Restrictions.eq("code", addressTypeCode))
				.add(Restrictions.eq("addressCategory", addressCategory))
				.uniqueResult();
			if(addressType != null){
			//	Hibernate.initialize(person.getProfile());				
			}
		} catch (HibernateException e) {
			LOG.error(e);
			throw e;
		}
		return addressType;
	}

	
}
